public class ProxySearcher extends Searcher{
    ProxySearcher(RealSearcher realSearcher){
        this.searcher = realSearcher;
    }

    RealSearcher searcher;
    AccessValidator validator = new AccessValidator();
    Logger logger = new Logger();

    public String doSearch(String userId, String keyword){
        if(!validator.validate(userId)){
            return "身份验证不通过，不是天才选手Uzi";
        }
        logger.log(userId);
        return searcher.doSearch(userId, keyword);
    }

    public boolean validate(String userId){
        return true;
    }

    public void log(String userId){
        System.out.println(userId);
    }
}
